﻿Imports System.ComponentModel
<Serializable()> _
Public Class EventBase
    Implements INotifyPropertyChanged



#Region "Members"
    Private m_eventID As Integer
    Private m_eventType As EventsType
    Private m_TimeFrame As TimeFrame
    Private m_EventArea As EventRectangle
    Private m_GuiRectangles As GuiRectangle

    Private m_YesResultsList As List(Of Result)
    Private m_NoResultsList As List(Of Result)


    Private m_OnClickEfectColor As Color

    Private m_text As String
    Private m_isFlickering As Boolean
    Private m_BackroundImageID As Integer
    Private m_NumOfFrames As Integer
    Private m_secondaryLocation As EventRectangle
    Private m_backgroundColor As Color = Colors.Transparent

#End Region

#Region "Constructors"
    Public Sub New(ByVal p_ID As Integer, ByVal p_eventRectangle As EventRectangle)
        m_eventType = EventsType.HotSpot
        m_eventID = p_ID
        m_EventArea = p_eventRectangle
        m_TimeFrame = Nothing
        m_GuiRectangles = Nothing
        m_YesResultsList = New List(Of Result)
        m_NoResultsList = New List(Of Result)
        NumOfFrames = 1

    End Sub

    Public Sub New()
        m_YesResultsList = New List(Of Result)
        m_NoResultsList = New List(Of Result)
        NumOfFrames = 1
        m_EventArea = New EventRectangle(New Point(0, 0), New Point(0, 0))

    End Sub

#End Region

#Region "Properties"

    Public Property NumOfFrames() As Integer
        Get
            Return m_NumOfFrames
        End Get
        Set(ByVal value As Integer)
            m_NumOfFrames = value
        End Set
    End Property

    Public Property NoResultsList() As List(Of Result)
        Get
            Return m_NoResultsList
        End Get
        Set(ByVal value As List(Of Result))
            m_NoResultsList = value
        End Set
    End Property

    Public Property SecondaryLocation() As EventRectangle
        Get
            Return m_secondaryLocation
        End Get
        Set(ByVal value As EventRectangle)
            m_secondaryLocation = value
        End Set
    End Property

    Public Property YesResultsList() As List(Of Result)
        Get
            Return m_YesResultsList
        End Get
        Set(ByVal value As List(Of Result))
            m_YesResultsList = value
        End Set
    End Property

    Public Event PropertyChanged As PropertyChangedEventHandler _
        Implements INotifyPropertyChanged.PropertyChanged

    Private Sub NotifyPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub


    Public Property alpha() As Integer
        Get
            Return BackgroundColor.A
        End Get
        Set(ByVal value As Integer)
            m_backgroundColor.A = value
            Dim l_oldcolor = BackgroundColor
            l_oldcolor.A = value
            m_GuiRectangles.Rectangel.Fill = New SolidColorBrush(l_oldcolor)
            NotifyPropertyChanged("alpha")
        End Set
    End Property

    <Xml.Serialization.XmlIgnore()> _
    Public Property BackgroundColor() As Color
        Get
            Return m_backgroundColor
        End Get
        Set(ByVal value As Color)
            m_backgroundColor = value
            Try
                GuiRectangle.Rectangel.Fill = New SolidColorBrush(value)
            Catch ex As Exception

            End Try

            NotifyPropertyChanged("BackgroundColor")
        End Set
    End Property

    <Xml.Serialization.XmlIgnore()> _
    Public Property OnClickEfectColor() As Color
        Get
            Return m_OnClickEfectColor
        End Get
        Set(ByVal value As Color)
            m_OnClickEfectColor = value
            NotifyPropertyChanged("OnClickEfectColor")
        End Set
    End Property

    Public Property Text() As String
        Get
            Return m_text
        End Get
        Set(ByVal value As String)
            m_text = value
            NotifyPropertyChanged("Text")
        End Set
    End Property

    Public Property IsFlickering() As Boolean
        Get
            Return m_isFlickering
        End Get
        Set(ByVal value As Boolean)
            m_isFlickering = value
            NotifyPropertyChanged("IsFlickering")
        End Set
    End Property

    Public Property BackroundImageID() As Integer
        Get
            Return m_BackroundImageID
        End Get
        Set(ByVal value As Integer)
            m_BackroundImageID = value
            NotifyPropertyChanged("BackroundImageID")
        End Set
    End Property


    <Xml.Serialization.XmlIgnore()> _
    Public Property GuiRectangle() As GuiRectangle
        Get
            Return m_GuiRectangles
        End Get
        Set(ByVal value As GuiRectangle)
            m_GuiRectangles = value
            NotifyPropertyChanged("BackroundImageID")
        End Set
    End Property


    Public Property TimeFrame() As TimeFrame
        Get
            Return m_TimeFrame
        End Get
        Set(ByVal value As TimeFrame)
            m_TimeFrame = value
            NotifyPropertyChanged("TimeFrame")
            NotifyPropertyChanged("FromTime")
            NotifyPropertyChanged("ToTime")
        End Set
    End Property

    Public Property FromTime() As TimeSpan
        Get
            Return m_TimeFrame.FromTime
        End Get
        Set(ByVal value As TimeSpan)
            m_TimeFrame.FromTime = value
            NotifyPropertyChanged("FromTime")
        End Set
    End Property

    Public Property ToTime() As TimeSpan
        Get
            Return m_TimeFrame.ToTime
        End Get
        Set(ByVal value As TimeSpan)
            m_TimeFrame.ToTime = value
            NotifyPropertyChanged("ToTime")
        End Set
    End Property

    Public Property EventArea() As EventRectangle
        Get
            Return m_EventArea
        End Get
        Set(ByVal value As EventRectangle)
            m_EventArea = value
            NotifyPropertyChanged("EventArea")
        End Set
    End Property

    Public Property EventID() As Integer
        Get
            Return m_eventID
        End Get
        Set(ByVal value As Integer)
            m_eventID = value
            NotifyPropertyChanged("EventID")
        End Set
    End Property

    Public Property EventType() As EventsType
        Get
            Return m_eventType
        End Get
        Set(ByVal value As EventsType)
            m_eventType = value
            NotifyPropertyChanged("EventType")
        End Set
    End Property
    Public Property TopLeft() As Point
        Get
            Return m_EventArea.TopLeft
        End Get
        Set(ByVal value As Point)
            m_EventArea.TopLeft = value
            NotifyPropertyChanged("TopLeft")
        End Set
    End Property

    Public Property BottomRight() As Point
        Get
            Return m_EventArea.BottomRight
        End Get
        Set(ByVal value As Point)
            m_EventArea.BottomRight = value
            NotifyPropertyChanged("BottomRight")
        End Set
    End Property

#End Region


#Region "XmlSerializer"

#Region "Consts"
    Private Const ID As String = "id"
    Private Const TYPE As String = "type"
    Private Const GAL_EVENT_TYPE As String = "GalEventType"
    Private Const IS_VISIBLE As String = "isVisible"
    Private Const IS_SHOW_EFFECT As String = "isShowClickEffect"
    Private Const CLICK_EFFECT_COLOR As String = "clickEffectColor"
    Private Const URL_FILE As String = "url"
    Private Const FILE_NAME As String = "fileName"
    Private Const FILE_SUFFIX As String = "fileSuffix"

    Private Const ELEMENT_TYPE As String = "elementType"
    Private Const TOP_LEFT As String = "locationTopLeft"
    Private Const BOTTOM_RIGHT As String = "locationBottomRight"
    Private Const COLOR As String = "color"
    Private Const TEXT_ As String = "text"
    Private Const IS_FLICKERING As String = "isFlickering"

    Private Const PRIM_TOP_LEFT As String = "primLocationTopLeft"
    Private Const PRIM_BOTTOM_RIGHT As String = "primLocationBottomRight"
    Private Const SECONDARY_TOP_LEFT As String = "secLocationTopLeft"
    Private Const SECONDARY_BOTTOM_RIGHT As String = "secLocationBottomRight"
    Private Const NUM_OF_FRAMES As String = "numOfFrames"


    Private Const START As String = "Start"
    Private Const END_ As String = "End"

    Private Const MOTION_TYPE = "motionType"

    Private Const BACKGROUND_IMAGE_ID As String = "BackgroundImageID"

    Private Const RESULTS_YES = "ResultsYes"
    Private Const RESULTS_NO = "ResultsNo"

#End Region

    Public Sub DeserializeGlobalEventXml(ByVal p_xelement As XElement)
        EventID = p_xelement.Attribute(ID).Value
        Me.EventType = EventsType.Text
        GetLocationAttributesFromXML(p_xelement)
        Me.BackgroundColor = FromRGBA(p_xelement.Attribute(COLOR).Value)
        Me.Text = p_xelement.Attribute(TEXT_).Value.ToString

        'build GUI_Rectangle

        Dim l_rectangle As New Rectangle
        l_rectangle.Stroke = New SolidColorBrush(Colors.LightGreen)

        If Me.EventType = EventsType.ButtonClick Then
            l_rectangle.Fill = New SolidColorBrush(Colors.LightGray)
        End If

        l_rectangle.Width = Math.Abs(EventArea.TopLeft.X - EventArea.BottomRight.X)
        l_rectangle.Height = Math.Abs(EventArea.TopLeft.Y - EventArea.BottomRight.Y)

        Me.GuiRectangle = New GuiRectangle(l_rectangle, New Point(EventArea.TopLeft.X, EventArea.TopLeft.Y))
        GuiRectangle.TextBlock = New TextBlock
        GuiRectangle.TextBlock.Text = Text

        Me.BackgroundColor = FromRGBA(p_xelement.Attribute(COLOR).Value)

    End Sub

    Public Sub XMLDeserialize(ByVal p_Xelement As XElement, ByVal p_mediaFiles As List(Of MediaFile))
        Me.EventID = p_Xelement.Attribute(ID).Value
        m_eventType = GetGalEventTypeFromString(p_Xelement.Attribute(GAL_EVENT_TYPE).Value)
        Dim l_EventType As EventType = GetEventTypeFromString(p_Xelement.Attribute(TYPE).Value)

        If l_EventType = GameEditor.EventType.click OrElse l_EventType = GameEditor.EventType.tuochScreen Then
            GetClickEventAttributesFromXML(p_Xelement)
        ElseIf l_EventType = GameEditor.EventType.showMovablePicture Then
            GetMovablePictureAttributesFromXml(p_Xelement)
        ElseIf l_EventType = GameEditor.EventType.motion Then
            GetMotionEventAttributesFromXML(p_Xelement)
        End If


        'build GUI_Rectangle

        Dim l_rectangle As New Rectangle
        l_rectangle.Stroke = New SolidColorBrush(Colors.LightGreen)

        If Me.EventType = EventsType.ButtonClick Then
            l_rectangle.Fill = New SolidColorBrush(Colors.LightGray)
        End If

        l_rectangle.Width = Math.Abs(EventArea.TopLeft.X - EventArea.BottomRight.X)
        l_rectangle.Height = Math.Abs(EventArea.TopLeft.Y - EventArea.BottomRight.Y)

        Me.GuiRectangle = New GuiRectangle(l_rectangle, New Point(EventArea.TopLeft.X, EventArea.TopLeft.Y))

        If EventType = EventsType.ButtonClick OrElse EventType = EventsType.Text Then

            Me.GuiRectangle.Rectangel.Fill = New SolidColorBrush(BackgroundColor)
            Me.GuiRectangle.TextBlock.Text = Me.Text
            Me.GuiRectangle.TextBlock.FontStretch = FontStretches.Expanded

        ElseIf EventType = EventsType.MovablePicture OrElse EventType = EventsType.PictureBox Then
            Dim l_imgs As New ImageSourceConverter
            Dim l_mediaFile = (From l_file In p_mediaFiles Where l_file.ID = BackroundImageID Select l_file).Single
            Dim l_ImageSource = CType(l_imgs.ConvertFromString(l_mediaFile.Path), ImageSource)
            'ImageBrush1.ImageSource = l_ImageSource

            Dim l_brush As New ImageBrush


            l_brush.ImageSource = l_ImageSource

            GuiRectangle.Rectangel.Fill = l_brush
        End If

        Dim l_xTimeFrame = p_Xelement.Element("TimeFrame")
        TimeFrame = New TimeFrame(New TimeSpan(0, 0, 0, 0, l_xTimeFrame.Element(START).Value), New TimeSpan(0, 0, 0, 0, l_xTimeFrame.Element(END_).Value))

        Dim l_xYesResults = p_Xelement.Element(RESULTS_YES)
        For Each l_xYesResult In l_xYesResults.Elements
            Dim l_result As New Result(0)
            l_result.XmlDesirialize(l_xYesResult, p_mediaFiles)
            Me.YesResultsList.Add(l_result)
        Next
        Dim l_xNoResults = p_Xelement.Element(RESULTS_NO)
        For Each l_xnoResult In l_xNoResults.Elements
            Dim l_result As New Result(0)
            l_result.XmlDesirialize(l_xnoResult, p_mediaFiles)
            Me.NoResultsList.Add(l_result)
        Next

    End Sub

   

    Private Function GetGalEventTypeFromString(ByVal p_typeString As String) As EventsType
        If p_typeString.Equals(EventsType.ButtonClick.ToString) Then
            Return EventsType.ButtonClick
        ElseIf p_typeString.Equals(EventsType.HotSpot.ToString) Then
            Return EventsType.HotSpot
        ElseIf p_typeString.Equals(EventsType.MovablePicture.ToString) Then
            Return EventsType.MovablePicture
        ElseIf p_typeString.Equals(EventsType.PictureBox.ToString) Then
            Return EventsType.PictureBox
        ElseIf p_typeString.Equals(EventsType.Shake.ToString) Then
            Return EventsType.Shake

        ElseIf p_typeString.Equals(EventsType.Text.ToString) Then
            Return EventsType.Text
        ElseIf p_typeString.Equals(EventsType.WheelLeft.ToString) Then
            Return EventsType.WheelLeft
        ElseIf p_typeString.Equals(EventsType.WheelRight.ToString) Then
            Return EventsType.WheelRight
        End If
    End Function

    Private Function GetEventTypeFromString(ByVal p_StringType As String) As EventType
        If p_StringType.Equals(GameEditor.EventType.click.ToString) Then
            Return GameEditor.EventType.click
        ElseIf p_StringType.Equals(GameEditor.EventType.keybord.ToString) Then
            Return GameEditor.EventType.keybord
        ElseIf p_StringType.Equals(GameEditor.EventType.motion.ToString) Then
            Return GameEditor.EventType.motion
        ElseIf p_StringType.Equals(GameEditor.EventType.showMovablePicture.ToString) Then
            Return GameEditor.EventType.showMovablePicture
        ElseIf p_StringType.Equals(GameEditor.EventType.tuochScreen.ToString) Then
            Return GameEditor.EventType.tuochScreen
        ElseIf p_StringType.Equals(GameEditor.EventType.voice.ToString) Then
            Return GameEditor.EventType.voice

        End If
        
    End Function

    Public Function GetXMLString(ByVal p_MediaFiles As List(Of MediaFile)) As XElement
        Dim l_XElement As New XElement("Event")
        l_XElement.Add(New XAttribute(ID, EventID))
        l_XElement.Add(New XAttribute(TYPE, GetEventType(Me.EventType)))
        l_XElement.Add(New XAttribute(GAL_EVENT_TYPE, Me.EventType))

        Dim l_EventType As GameEditor.EventType = GetEventType(Me.EventType)
        If l_EventType = GameEditor.EventType.click OrElse l_EventType = GameEditor.EventType.tuochScreen Then
            InsertClickEventAttributes(l_XElement, p_MediaFiles)
        ElseIf l_EventType = GameEditor.EventType.showMovablePicture Then
            InsertMovablePictureAttributes(l_XElement, p_MediaFiles)
        ElseIf l_EventType = GameEditor.EventType.motion Then
            InsertMotionEventAttributes(l_XElement)

        End If

        Dim l_xTimeFrames As New XElement("TimeFrame")
        l_XElement.Add(l_xTimeFrames)

        Dim l_xStart As New XElement(START)
        l_xTimeFrames.Add(l_xStart)
        l_xStart.Add(Me.TimeFrame.FromTime.TotalMilliseconds.ToString)

        Dim l_xEnd As New XElement(END_)
        l_xTimeFrames.Add(l_xEnd)
        l_xEnd.Add(Me.TimeFrame.ToTime.TotalMilliseconds.ToString)

        Dim l_XResultsYes As New XElement(RESULTS_YES)
        l_XElement.Add(l_XResultsYes)
        For Each l_Result In m_YesResultsList
            l_XResultsYes.Add(l_Result.GetXMLString(p_MediaFiles))
        Next


        Dim l_xResultNo As New XElement(RESULTS_NO)
        l_XElement.Add(l_xResultNo)
        For Each l_result In m_NoResultsList
            l_xResultNo.Add(l_result.GetXMLString(p_MediaFiles))
        Next


        Return l_XElement

    End Function

    Private Sub InsertMotionEventAttributes(ByRef p_xElement As XElement)
        p_xElement.Add(New XAttribute(MOTION_TYPE, GetMotionType))
        InsertLocationAttributes(p_xElement)
    End Sub
    Private Sub GetMotionEventAttributesFromXML(ByVal p_xelelement As XElement)
        GetLocationAttributesFromXML(p_xelelement)
    End Sub

    Private Sub GetClickEventAttributesFromXML(ByVal p_xelement As XElement)
        Try
            If Not CBool(p_xelement.Attribute(IS_SHOW_EFFECT).Value) Then
                Me.OnClickEfectColor = New System.Windows.Media.Color
                m_OnClickEfectColor.A = 0
                m_OnClickEfectColor.R = 0
                m_OnClickEfectColor.G = 0
                m_OnClickEfectColor.B = 0
            Else
                Me.OnClickEfectColor = FromRGBA(p_xelement.Attribute(CLICK_EFFECT_COLOR).Value)
            End If

            Dim l_Val = p_xelement.Attribute(BACKGROUND_IMAGE_ID).Value
            If String.IsNullOrEmpty(l_Val) Then
                BackroundImageID = 0
            Else
                BackroundImageID = l_Val
            End If

            GetLocationAttributesFromXML(p_xelement)
            Me.m_backgroundColor = FromRGBA(p_xelement.Attribute(COLOR).Value)
            Me.Text = p_xelement.Attribute(TEXT_).Value
            Me.IsFlickering = p_xelement.Attribute(IS_FLICKERING).Value
            Me.NumOfFrames = p_xelement.Attribute(NUM_OF_FRAMES).Value

        Catch ex As Exception

        End Try
        

    End Sub

    Private Function FromRGBA(ByVal p_RGBAString As String) As System.Windows.Media.Color
        Try
            Dim l_arr = p_RGBAString.Split(",")
            Dim l_color As New System.Windows.Media.Color
            l_color.R = l_arr(0)
            l_color.G = l_arr(1)
            l_color.B = l_arr(2)
            l_color.A = l_arr(3)
            Return l_color
        Catch ex As Exception

        End Try
        
    End Function
    Private Sub InsertClickEventAttributes(ByRef p_Xelement As XElement, ByVal p_mediaFiles As List(Of MediaFile))
        Try
            If Me.OnClickEfectColor.A = 0 AndAlso Me.OnClickEfectColor.B = 0 AndAlso OnClickEfectColor.R = 0 AndAlso OnClickEfectColor.G = 0 Then
                p_Xelement.Add(New XAttribute(IS_SHOW_EFFECT, False))
            Else
                p_Xelement.Add(New XAttribute(IS_SHOW_EFFECT, True))
            End If
            p_Xelement.Add(New XAttribute(IS_VISIBLE, True))

            p_Xelement.Add(New XAttribute(CLICK_EFFECT_COLOR, GameInfo.GetRGBA(Me.OnClickEfectColor)))

            InsertURLFileAttributes(p_Xelement, p_mediaFiles)

            InsertLocationAttributes(p_Xelement)
            p_Xelement.Add(New XAttribute(ELEMENT_TYPE, GameInfo.GetUIElementType(Me.EventType)))
            p_Xelement.Add(New XAttribute(COLOR, GameInfo.GetRGBA(BackgroundColor)))
            p_Xelement.Add(New XAttribute(TEXT_, Text))
            p_Xelement.Add(New XAttribute(IS_FLICKERING, IsFlickering))
            p_Xelement.Add(New XAttribute(NUM_OF_FRAMES, NumOfFrames))

        Catch ex As Exception
            MsgBox("Error occured while trying to parse eventID: " & EventID)
        End Try

    End Sub



    Private Sub InsertURLFileAttributes(ByVal p_xElement As XElement, ByVal p_mediaFiles As List(Of MediaFile))
        Dim l_Url As String = ""
        Dim l_FileName As String = ""
        Dim l_FileSuffix As String = ""

        If (Not BackroundImageID.Equals(String.Empty)) AndAlso BackroundImageID <> 0 Then

            l_Url = (From l_MediaFile In p_mediaFiles Where l_MediaFile.ID = BackroundImageID Select l_MediaFile.Url).Single
            l_FileName = IO.Path.GetFileNameWithoutExtension(l_Url)
            l_FileSuffix = IO.Path.GetExtension(l_Url).Substring(1)
        End If

        p_xElement.Add(New XAttribute(URL_FILE, l_Url))
        p_xElement.Add(New XAttribute(FILE_NAME, l_FileName))
        p_xElement.Add(New XAttribute(FILE_SUFFIX, l_FileSuffix))
        p_xElement.Add(New XAttribute(BACKGROUND_IMAGE_ID, Me.BackroundImageID))
    End Sub

    Private Sub InsertLocationAttributes(ByRef p_xelement As XElement)
        p_xelement.Add(New XAttribute(TOP_LEFT, EventArea.TopLeft))
        p_xelement.Add(New XAttribute(BOTTOM_RIGHT, EventArea.BottomRight))
    End Sub

    Private Sub GetLocationAttributesFromXML(ByVal p_xelement As XElement)
        Dim l_arrTopLeft = p_xelement.Attribute(TOP_LEFT).Value.Split(",")
        Me.EventArea.TopLeft = New Point(l_arrTopLeft(0), l_arrTopLeft(1))

        Dim l_arrBottomRight = p_xelement.Attribute(BOTTOM_RIGHT).Value.Split(",")
        Me.EventArea.BottomRight = New Point(l_arrBottomRight(0), l_arrBottomRight(1))

    End Sub

    Private Sub GetMovablePictureAttributesFromXml(ByVal p_xelement As XElement)
        Try
            Dim l_arrTopLeft = p_xelement.Attribute(PRIM_TOP_LEFT).Value.Split(",")
            Me.EventArea.TopLeft = New Point(l_arrTopLeft(0), l_arrTopLeft(1))

            Dim l_arrBottomRight = p_xelement.Attribute(PRIM_BOTTOM_RIGHT).Value.Split(",")
            Me.EventArea.BottomRight = New Point(l_arrBottomRight(0), l_arrBottomRight(1))



            Dim l_arr2TopLeft = p_xelement.Attribute(SECONDARY_TOP_LEFT).Value.Split(",")
            Dim l_2ndTopLeft = New Point(l_arr2TopLeft(0), l_arr2TopLeft(1))

            Dim l_arr2BottomRight = p_xelement.Attribute(SECONDARY_BOTTOM_RIGHT).Value.Split(",")
            Dim l_2ndbBottomRight = New Point(l_arr2BottomRight(0), l_arr2BottomRight(1))

            Me.SecondaryLocation = New EventRectangle(l_2ndTopLeft, l_2ndbBottomRight)

            Me.BackroundImageID = p_xelement.Attribute(BACKGROUND_IMAGE_ID).Value
            Me.NumOfFrames = p_xelement.Attribute(NUM_OF_FRAMES).Value
        Catch ex As Exception

        End Try
       

    End Sub

    Private Sub InsertMovablePictureAttributes(ByRef p_Xelement As XElement, ByVal p_mediaFiles As List(Of MediaFile))
        Try
            p_Xelement.Add(New XAttribute(PRIM_TOP_LEFT, EventArea.TopLeft))
            p_Xelement.Add(New XAttribute(PRIM_BOTTOM_RIGHT, EventArea.BottomRight))
            p_Xelement.Add(New XAttribute(SECONDARY_TOP_LEFT, SecondaryLocation.TopLeft))
            p_Xelement.Add(New XAttribute(SECONDARY_BOTTOM_RIGHT, SecondaryLocation.BottomRight))
            p_Xelement.Add(New XAttribute(NUM_OF_FRAMES, NumOfFrames))

            InsertURLFileAttributes(p_Xelement, p_mediaFiles)
        Catch ex As Exception
            MsgBox("Error - Some movable picture properties not set...")
        End Try


    End Sub

    Private Function GetEventType(ByVal p_eventType As EventsType) As EventType

        Select Case p_eventType
            Case EventsType.ButtonClick
                Return GameEditor.EventType.click
            Case EventsType.MovablePicture
                Return GameEditor.EventType.showMovablePicture
            Case EventsType.Text
                Return GameEditor.EventType.click
            Case EventsType.HotSpot
                Return GameEditor.EventType.tuochScreen
            Case EventsType.PictureBox
                Return GameEditor.EventType.click
            Case EventsType.WheelLeft
                Return GameEditor.EventType.motion
            Case EventsType.WheelRight
                Return GameEditor.EventType.motion
            Case EventsType.Shake
                Return GameEditor.EventType.motion
            Case Else


        End Select
    End Function

    Private Function GetMotionType() As MotionType

        Select Case Me.EventType
            Case EventsType.Shake
                Return MotionType.Shake
            Case EventsType.WheelLeft
                Return MotionType.WheelLeft
            Case EventsType.WheelRight
                Return MotionType.WheelRight
            Case Else

        End Select

    End Function
#End Region

End Class
